<?
if(!defined('L_ADMOD')) {echo "<meta http-equiv='refresh' content='0; url=/?nma=error&act=403'>";exit;}
include("./inc/bloced.php");


if (!isset($goto) || !isset($taction) || $goto=='' || $taction=='')
{
	print "<br><br><center><b>"._ERROR_.": "._NOITEMS_."</b></center>";
	echo "<meta http-equiv='refresh' content='2; url=/admin.php?op=".$op."'>";
}else
{
	if($goto=='links')
	{
		if($taction=='actnew')
		{
			$query="UPDATE ${wcpref}".$op." SET mod_block='0' WHERE mod_id='".$lid."'";
			if(mysql_query($query))
			{
				print "<br><br><center><b>"._WAITMESSAGE_."</b></center>";
				echo "<meta http-equiv='refresh' content='0; url=/admin.php?op=".$op."&flag=".$goto."&item=".$item."'>";
			}
		}elseif($taction=='noactnew')
		{
			$query="UPDATE ${wcpref}".$op." SET mod_block='1' WHERE mod_id='".$lid."'";
			if(mysql_query($query))
			{
				print "<br><br><center><b>"._WAITMESSAGE_."</b></center>";
				echo "<meta http-equiv='refresh' content='0; url=/admin.php?op=".$op."&flag=".$goto."&item=".$item."'>";
			}
		}elseif($taction=='toban')
		{
			$query="UPDATE ${wcpref}".$op." SET mod_ban='1' WHERE mod_id='".$lid."'";
			if(mysql_query($query))
			{
				print "<br><br><center><b>"._WAITMESSAGE_."</b></center>";
				echo "<meta http-equiv='refresh' content='0; url=/admin.php?op=".$op."&flag=".$goto."&item=".$item."'>";
			}
		}elseif($taction=='outban')
		{
			$query="UPDATE ${wcpref}".$op." SET mod_ban='0' WHERE mod_id='".$lid."'";
			if(mysql_query($query))
			{
				print "<br><br><center><b>"._WAITMESSAGE_."</b></center>";
				echo "<meta http-equiv='refresh' content='0; url=/admin.php?op=".$op."&flag=".$goto."&item=".$item."'>";
			}
		}
		
	}elseif($goto=='forall')
	{
		if($taction=='dellink')
		{
			$query="DELETE FROM ${wcpref}".$op." WHERE mod_id='".$lid."'";
			if(mysql_query($query))
			{
				print "<br><br><center><b>"._WAITMESSAGE_."</b></center>";
				echo "<meta http-equiv='refresh' content='0; url=/admin.php?op=".$op."&flag=links&item=".$item."'>";
			}else
			{
				print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font> '._ERRORADDQUERY_.'</b></center>';
				echo "<meta http-equiv='refresh' content='2; url=/admin.php?op=".$op."'>";
			}
		}
	}elseif($goto=='linksfrm')
	{
		$old_val = array('\"', 'http://');
		$new_val   = array('"', '');
		$trans = get_html_translation_table(HTML_ENTITIES);
		$trans = array_flip($trans);
		
		$check_url=$new_url;
		$check_url=str_replace($old_val, $new_val, $check_url);
		$check_url='http://'.$check_url;
		$parsed = parse_url($check_url);
		$check_url=$parsed['host'];
		$check_url=str_replace($old_val, $new_val, $check_url);
		
		$check_rurl=$new_rurl;
		$check_rurl=str_replace($old_val, $new_val, $check_rurl);
		
		$check_name=$new_name;

		$check_short = strtr($new_short, $trans);
		$check_short = str_replace($old_val, $new_val, $check_short);
		
		$check_full = strtr($new_full, $trans);
		$check_full = str_replace($old_val, $new_val, $check_full);
		
		if($taction=='editlink')
		{
			$query="UPDATE ${wcpref}".$op." SET 
				mod_cat_id='".$cid."',
				mod_url='".$check_url."',
				mod_name='".$check_name."',
				mod_short='".$check_short."',
				mod_full='".$check_full."',
				mod_reverse_url='".$check_rurl."'
			WHERE mod_id='".$lid."'";
			if(mysql_query($query))
			{
				print "<br><br><center><b>"._WAITMESSAGE_."</b></center>";
				echo "<meta http-equiv='refresh' content='0; url=/admin.php?op=".$op."&flag=index'>";
			}else
			{
				print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font> '._ERRORADDQUERY_.'</b></center>';
				echo "<meta http-equiv='refresh' content='2; url=/admin.php?op=".$op."'>";
			}
		}elseif($taction=='addlink')
		{
			$query="INSERT INTO ${wcpref}".$op." VALUES (
				NULL,
				'".$cid."',
				'".$check_url."',
				'".$check_name."',
				'".$check_short."',
				'".$check_full."',
				'".$wccat_block."',
				'0',
				'0',
				'".$_SESSION['user_id']."',
				'".$check_rurl."',
				'',
				'0',
				now()
			)";
			if(mysql_query($query))
			{
				print "<br><br><center><b>"._WAITMESSAGE_."</b></center>";
				echo "<meta http-equiv='refresh' content='0; url=/admin.php?op=".$op."&flag=links&item=newlinks'>";
			}else
			{
				print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font> '._ERRORADDQUERY_.'</b></center>';
				echo "<meta http-equiv='refresh' content='2; url=/admin.php?op=".$op."'>";
			}
		}
	}
}
?>